<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<html>
	<!-- Mirrored from www.zi-han.net/theme/hplus/table_jqgrid.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:02 GMT -->
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>H+ 后台主题UI框架 - jqGird</title>
		<%@ include file="/WEB-INF/pages/common/inc.jsp"%>
		<link href="${ctxStatic}/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
		<link href="${ctxStatic}/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
		<!-- jqgrid-->
		<link href="${ctxStatic}/css/plugins/jqgrid/ui.jqgridffe4.css?0820" rel="stylesheet">
		<link href="${ctxStatic}/css/animate.min.css" rel="stylesheet">
		<link href="${ctxStatic}/css/style.min862f.css?v=4.1.0" rel="stylesheet">
		<style>
			.ui-jqgrid-sortable,.jqgrow,.ui-pg-table,.EditTable{
				font-size:12px;
			}
		</style>
	</head>

	<body>
		<div id="page_button" align="right">
			<shiro:hasRole name="admin">
				<button type="button" class="btn btn-w-m btn-success" onclick="opera('1')">通过</button>
			</shiro:hasRole>
			<button type="button" class="btn btn-w-m btn-danger" onclick="opera('2')">下架</button>
		</div>
		<table id="table_list_2"></table>
		<div id="pager_list_2"></div>
		<script src="${ctxStatic}/js/jquery.min.js?v=2.1.4"></script>
		<script src="${ctxStatic}/js/bootstrap.min.js?v=3.3.6"></script>
		<script src="${ctxStatic}/js/plugins/peity/jquery.peity.min.js"></script>
		<script src="${ctxStatic}/js/plugins/jqgrid/i18n/grid.locale-cnffe4.js?0820"></script>
		<script src="${ctxStatic}/js/plugins/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>
		<script src="${ctxStatic}/js/content.min.js?v=1.0.0"></script>
		<script>
			$(document).ready(function() {
				$("#table_list_2").css('fontSize','14px');
				$("#pager_list_2").css('fontSize','14px');
				$.jgrid.defaults.styleUI = "Bootstrap";
					$("#table_list_2").jqGrid({
						url : '${ctx}/admin/goods/listGoods',
					    datatype : "json",
						height: "420",
						autowidth: true,
						shrinkToFit: true,
						multiselect : true,
						rownumbers:true,
						viewrecords:true,
						rowNum: 10,
						rowList: [10, 20, 30],
						colNames: ["用户id","名称", "类型","长度", "宽度","高度", "重量","功率","状态","创建时间","操作"],
						colModel: [{
							name: "id",
							index: "id",
							editable: true,
							hidden:true,
							key:true
						},{
							name: "name",
							index: "name",
							editable: true
						},{
							name: "type",
							index: "type",
							editable: true
						},{
							name: "length",
							index: "length",
						},{
							name: "width",
							index: "width",
						},{
							name: "height",
							index: "height",
						},{
							name: "weight",
							index: "weight",
						},{
							name: "power",
							index: "power",
						},{
							name: "status",
							index: "status",
							formatter:function(cellvalue, options, rowObject){
								if(cellvalue == 0){
									return "待审核";
								} else if(cellvalue == 1){
									return "已发布";
								} else if(cellvalue == 2){
									return "已下架";
								}
							}
						},{
							name: "create_date",
							index: "create_date",
						},{
							name: "status",
							index: "status",
							width : 170,
							formatter:function(cellvalue, options, rowObject){
								return "<a href='${ctx}/admin/goods/operateGoods?oper=look&id="+rowObject.id+"' class='btn btn-white btn-bitbucket'><i class='fa fa-search'></i></a><a href='${ctx}/admin/goods/operateGoods?oper=edit&id="+rowObject.id+"' class='btn btn-white btn-bitbucket'><i class='fa fa-wrench'></i></a>";
							}
						}],
						pager: "#pager_list_2",
						sortname : 'id',
						editurl:"${ctx}/admin/goods/operateGoods",
						sortorder : "desc"
					});
		
					$("#table_list_2").jqGrid("navGrid", "#pager_list_2", {
						edit: false,
						add: false,
						del: true,
						search: true
					});
			});
			
			function opera(type){
				var ids=$("#table_list_2").jqGrid("getGridParam","selarrrow");
				if(ids == ""){
					alert("请选择一条商品进行操作");
				} else {
					if(type == 1){//审核
						$.get('${ctx}/admin/goods/operateGoods?oper=pass&ids='+ids,function(){
							$("#table_list_2").trigger("reloadGrid");
						});
					} else if(type == 2){ //下架
						$.get('${ctx}/admin/goods/operateGoods?oper=down&ids='+ids,function(){
							$("#table_list_2").trigger("reloadGrid");
						});
					}
				}
			}
			
			function alone(type,id){
				if(type == 3){//预览页面
					
				} else if(type == 4){//跳到编辑页面
					$.get('${ctx}/admin/goods/operateGoods?oper=edit&id='+id);
				}
			}
		</script>
	</body>
</html>